const express = require("express")
const router = express.Router()

//规则
const { getGoodList_check, delGood_check, getGoodAttribute_check } = require("../check/goods")
//检验规则
const express_jwt = require("@escook/express-joi")

const { getGoodList, delGood, addGood, getGoodCategory, getGoodAttribute,
    getTotalLevel0Num, editCategoryName, delGoodCategory, getGoodCateTwoLevel
    , addGoodCategory } = require("../router_handle/goods")

//商品列表
router.get("/getGoodList", express_jwt(getGoodList_check), getGoodList)

//删除商品
router.delete("/delGood", express_jwt(delGood_check), delGood)

//类别数目（level0）
router.get("/getTotalLevel0Num", getTotalLevel0Num)

//商品类别（三级）
router.get("/getGoodCategory", getGoodCategory)

//商品类别（两级）
router.get("/getGoodCateTwoLevel", getGoodCateTwoLevel)

//获取商品属性(参数：第三级的id)
router.get("/getGoodAttribute", express_jwt(getGoodAttribute_check), getGoodAttribute)

//添加商品
router.post("/addGood", addGood)

//更改商品名称
router.post("/editCategoryName", editCategoryName)

//删除商品类别
router.post("/delGoodCategory", delGoodCategory)

//添加商品类别
router.post("/addGoodCategory", addGoodCategory)

module.exports = router